package com.jiuyou.clientController.headImage;

import com.jiuyou.clientController.base.ClientBaseController;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.common.core.domain.entity.StoreUserRole;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.fitment.domain.StoreFitment;
import com.ruoyi.fitment.service.IStoreFitmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chengliang
 * @date 2022/8/26
 **/
@RestController
@RequestMapping("/client/fitment")
public class HeadImageClientController extends ClientBaseController {
    @Autowired
    private IStoreFitmentService fitmentService;
    @RequestMapping("/getList/{type}/{id}")
    public TableDataInfo getList(@PathVariable String type,@PathVariable Long id){

        StoreFitment fitment = new StoreFitment();
        fitment.setStoreId(id);
        fitment.setMediaType(type);
        fitment.setFitmentType(DicConstants.FITMENT_TYPE_MULTIPLE.getCode());
        List<StoreFitment> storeFitments = fitmentService.selectStoreFitmentList(fitment);
        return getDataTable(storeFitments);
    }
    @RequestMapping("/getInfo/{id}")
    public StoreFitment getInfo(@PathVariable Long id){
        StoreFitment storeFitment = new StoreFitment();
        storeFitment.setStoreId(id);
        storeFitment.setFitmentType(DicConstants.FITMENT_TYPE_SINGLE.getCode());
        List<StoreFitment> storeFitments = fitmentService.selectStoreFitmentList(storeFitment);
        return storeFitments.get(0);
    }
}
